const fs = require('fs')
const path = require('path')
const { get, post, del } = require('../request')

const key = fs.readFileSync(path.resolve(__dirname, './ssl/server_key.pem')).toString()
const cert = fs.readFileSync(path.resolve(__dirname, './ssl/server.cer')).toString()
const passphrase = 'Changeme_123'

function reqWithSSL(url, header = {}) {
  return get(url, Object.assign({}, { 'x-domain-name': 'default' }, header), {
    cert,
    key,
    passphrase
  })
}

function delWithSSL(url, header = {}) {
  return del(url, Object.assign({}, { 'x-domain-name': 'default' }, header), {
    cert,
    key,
    passphrase
  })
}

module.exports = { reqWithSSL, delWithSSL }
